<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.8.6/dist/css/layui.css" rel="stylesheet">
</head>

<body>
    <button class="layui-btn" id="ID-dropdown-demo-content">
        自定义内容
        <i class="layui-icon layui-icon-list layui-font-14"></i>
    </button>
    <div id="test"></div>
    <style>
        .demo-dropdown-tabs {
            padding: 0 16px;
        }

        #test {
            background-color: red;
        }
    </style>

    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="//unpkg.com/layui@2.8.6/dist/layui.js"></script>
    <script>
        layui.use(function () {
            var element = layui.element;
            var dropdown = layui.dropdown;

            // 自定义内容
            dropdown.render({
                elem: '#ID-dropdown-demo-content',
                content: '<div id="test"></div>',
                className: 'demo-dropdown-tabs',
                style: 'width: 370px; height: 500px; box-shadow: 1px 1px 30px rgb(0 0 0 / 12%);',
                shade: 0.3, // 弹出时开启遮罩 --- 2.8+
                ready: function () {
                    layui.use('element', function (element) {
                        element.render('tab');
                    });
                }
            });


            var element = layui.element;
            var $ = layui.$;
            // 动态插入导航元素
            $('#test').html(`
    <div class="layui-nav" lay-filter="demo-filter-nav">
      <li class="layui-nav-item layui-this"><a href="">选中</a></li>
      <li class="layui-nav-item"><a href="">菜单</a></li>
      <!-- … -->
    </div>
  `);
            // 渲染导航组件
            element.render('nav', 'demo-filter-nav');
        });
    </script>

</body>

</html>